home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
GRAPH_FO
/
(GRAPH
/
GRAPH_SO
/
GRNODE.C
< prev
next >
Wrap
Text File
|
1991-06-13
|
3KB
|
151 lines
/******************************************************************************
GrNode.c
Graph methods in Object C.
This implements the GrNode class, base for GrVertex and GrEdge.
SUPERCLASS = CObject
Copyright ⌐ 1991 Maarten Meijer. All rights reserved.
CIS 100016,1764; FidoNet 2:512/114
*******************************************************************************/
#include "GrNode.h"
#include <Global.h>
/* GrNode methods ****************************************************/
void
GrNode::IGraphNode() {
hotRegion = NULL;
selected = false;
}
/* the copy method does not make new edges from a vertex or
copy the toVertex and fromVertex of an edge */
CObject *
GrNode::Copy() {
CObject *temp;
temp = inherited::Copy();
/* otherwise it is disposed !! */
((GrNode *)temp)->hotRegion = NULL;
((GrNode *)temp)->SetRegion();
return temp;
}
short
GrNode::Track() {
Point pt;
Boolean track;
InvertRgn(hotRegion);
while(Button()) {
GetMouse(&pt);
if(!(track = PtInRgn(pt, hotRegion)))
break;
}
InvertRgn(hotRegion);
if(track)
return 1; /* make part code possible */
else
return 0;
}
/******************************************************************************
_Draw & Draw
Draw the Node.
*******************************************************************************/
void
GrNode::_Draw() {
}
void
GrNode::Draw() {
}
void
GrNode::Select() {
selected = !false;
}
void
GrNode::Deselect() {
selected = false;
}
void
GrNode::ToggleNode(Boolean redraw) {
selected = !selected;
if(redraw)
Draw();
}
Boolean
GrNode::Selected() {
return (selected);
}
/******************************************************************************
Setting and accessing the hot region of the node.
The function _SetRegion should be changed to a method for GrList,
because this is accessing local variables from outside a class.
*******************************************************************************/
void
_SetRegion(GrNode *this) {
this->SetRegion();
}
void
GrNode::SetRegion() {
if(hotRegion != NULL)
DisposeRgn(hotRegion);
hotRegion = NewRgn();
}
Boolean
GrNode::PtInNode(Point where) {
return PtInRgn(where, hotRegion);
}
Boolean
GrNode::Incident(GrNode *which) {
return false;
}
/******************************************************************************
GetRect
Get the spanning rect, needed for redrawing.
*******************************************************************************/
void
GrNode::GetRect(Rect *rect) {
}
/******************************************************************************
NodeInRect
Determine or the node is inside the rect and needs to be redrawn.
This is necessary for speed reasons. With larger graphs it pays
of to determine or redrawing is necessary and not to depend on
the clipregion only.
*******************************************************************************/
Boolean
GrNode::NodeInRect(Rect *r) {
return FALSE;
}
/******************************************************************************
Dispose
Dont forget the hotRegion.
*******************************************************************************/
void
GrNode::Dispose() {
if(hotRegion != NULL)
DisposeRgn(hotRegion);
inherited::Dispose(); /* CObject */
}